{ stdenv, pkgs, fetchgit }:

stdenv.mkDerivation rec {
  name = "libolm";
  version = "3.2.4";

  src = fetchgit {
    url = "https://gitlab.matrix.org/matrix-org/olm/";
    rev = "64afab93645957846d936a19b8501dbd3f2cc4a1";
    sha256 = "1rl7j26li1irb1lqnnkzan7jrj38kvmdn69rlwbbp390v3z15lvh";
  };

  prePatch = ''
    substituteInPlace Makefile \
      --replace "/usr/bin/make" "/usr/bin/env make"
    substituteInPlace Makefile \
      --replace "/usr/local" "$out"
  '';
}
